package com.jp.knowledge.adapter;

import android.content.Context;
import android.support.annotation.NonNull;

import com.jp.knowledge.R;
import com.jp.knowledge.model.FoundAppData;
import com.jp.knowledge.my.base.RecycleVAdapter;
import com.jp.knowledge.my.base.RecycleVHolder;

import java.util.ArrayList;

/**
 * Created by 528787067@qq.com on 2017/3/14.
 */

public class HomePageIconsAdapter  extends RecycleVAdapter<FoundAppData> {

    public HomePageIconsAdapter(Context context, @NonNull ArrayList<FoundAppData> list) {
        super(context, list);
    }

    @Override
    public int getLayoutId(int viewType) {
        return R.layout.home_page_icon_item;
    }

    @Override
    public void onBind(RecycleVHolder holder, int position) {
        if(getData(position).getIcon() != null && getData(position).getIcon().trim().length() > 0)
            holder.setImageUrl(R.id.icon_img, getData(position).getIcon());
        else
            holder.setImageResource(R.id.icon_img, R.mipmap.headlines_whole);
        holder.setTextView(R.id.icon_title, getData(position).getName());
    }
}
